package log

import (
	"io"
	"os"
)

type Logger struct {
	access io.Writer
	error  io.Writer
	format string
}

func New(accessLog, errorLog string) (*Logger, error) {
	access, err := os.OpenFile(accessLog, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
	if err != nil {
		return nil, err
	}

	error, err := os.OpenFile(errorLog, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
	if err != nil {
		return nil, err
	}

	return &Logger{
		access: access,
		error:  error,
		format: "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent",
	}, nil
}
